package com.ating.demo.Exceptiom;

import com.ating.demo.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice("com.ating.demo.controller")//全局异常处理
public class GobalExceptionHandler {

    @ExceptionHandler(Exception.class)//捕获异常
    @ResponseBody//返回json类型
    public Result error(Exception  e){
        e.printStackTrace();
        return Result.error();
    }
}
